package Controller
{
	import Model.Address;
	import Model.ClimateZone;
	import Model.ContactInfo;
	import Model.ProjectInfo;
	
	import View.project.ProjectData;
	
	import flash.sampler.NewObjectSample;
	
	import mx.core.FlexGlobals;

	public class ProjectDataController
	{
		
		public function ProjectDataController()
		{
		}
		
		public function updateObjectInfo(objectName:String, objectAddress:Address):void
		{
			FlexGlobals.topLevelApplication.project.projectInfo.object.name = objectName;
			FlexGlobals.topLevelApplication.project.projectInfo.object.address = objectAddress;
		}
		
		public function updateObjectUISection():void
		{
			(FlexGlobals.topLevelApplication.screenCollection[0] as ProjectData).updateObjectSectionData(FlexGlobals.topLevelApplication.project.projectInfo.object);
		}

		public function updateBuilderInfo(builderName:String, builderAddress:Address):void
		{
			FlexGlobals.topLevelApplication.project.projectInfo.builder.name = builderName;
			FlexGlobals.topLevelApplication.project.projectInfo.builder.address = builderAddress;
		}
		
		public function updateBuilderUISection():void
		{
			(FlexGlobals.topLevelApplication.screenCollection[0] as ProjectData).updateBuilderSectionData(FlexGlobals.topLevelApplication.project.projectInfo.builder);
		}
		
		public function updateArchitectInfo(architectName:String, architectAddress:Address):void
		{
			FlexGlobals.topLevelApplication.project.projectInfo.architect.name = architectName;
			FlexGlobals.topLevelApplication.project.projectInfo.architect.address = architectAddress;
		}
		
		public function updateArchitectUISection():void
		{
			(FlexGlobals.topLevelApplication.screenCollection[0] as ProjectData).updateArchitectSectionData(FlexGlobals.topLevelApplication.project.projectInfo.architect);
		}
		
		public function updateNotes(note:String):void
		{
			FlexGlobals.topLevelApplication.project.projectInfo.notes = note;
		}
		
		public function updateNotesUISection():void
		{
			(FlexGlobals.topLevelApplication.screenCollection[0] as ProjectData).updateNotes(FlexGlobals.topLevelApplication.project.projectInfo.notes);
		}
		
		public function updateClimateZone(climateZone:ClimateZone):void
		{
			FlexGlobals.topLevelApplication.project.projectInfo.climateZone = climateZone;
		}
		
		public function updateClimateZoneUISection():void
		{
			(FlexGlobals.topLevelApplication.screenCollection[0] as ProjectData).updateClimateZone(FlexGlobals.topLevelApplication.project.projectInfo.climateZone.label);
		}
		
		public function updateConstructionType(constructionType:String):void
		{
			FlexGlobals.topLevelApplication.project.projectInfo.typeConstruction = constructionType;
		}
		
		public function updateConstructionTypeUISection():void
		{
			(FlexGlobals.topLevelApplication.screenCollection[0] as ProjectData).updateConstructionType(FlexGlobals.topLevelApplication.project.projectInfo.typeConstruction);
		}
		
		public function updateBuildingType(buildingType:String):void
		{
			FlexGlobals.topLevelApplication.project.projectInfo.buildingType = buildingType;
		}
		
		public function updateBuildingTypeUISection():void
		{
			(FlexGlobals.topLevelApplication.screenCollection[0] as ProjectData).updateBuildingType(FlexGlobals.topLevelApplication.project.projectInfo.buildingType);
		}
		
		public function updateUsage(usage:String):void
		{
			FlexGlobals.topLevelApplication.project.projectInfo.usage = usage;
		}
		
		public function updateUsageUISection():void
		{
			(FlexGlobals.topLevelApplication.screenCollection[0] as ProjectData).updateUsage(FlexGlobals.topLevelApplication.project.projectInfo.usage);
		}
		
		public function updateInteriorTemperature(interiorTemperature:Number):void
		{
			FlexGlobals.topLevelApplication.project.projectInfo.interiorTemperature = interiorTemperature;
		}
		
		public function getProjectInfo():ProjectInfo
		{
			return FlexGlobals.topLevelApplication.project.projectInfo;
		}
		
		public function updatePrjectDataUI():void
		{
			this.updateObjectUISection();
			this.updateArchitectUISection();
			this.updateBuilderUISection();
			this.updateNotesUISection();
			this.updateClimateZoneUISection();
			this.updateConstructionTypeUISection();
			this.updateBuildingTypeUISection();
			this.updateUsageUISection();

		}
	
	}
}